package com.yjian.auth;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by xuxiaobao on 2017/10/1.
 */
@Component
public class TokenRequestHeader {
    private String header = "X-Auth";
    public String getToken(HttpServletRequest httpServletRequest) {
        String token = httpServletRequest.getHeader(this.header);
        if (StringUtils.isEmpty(token)) {
            throw new RuntimeException("Token不能为空");
        }
        return token;
    }
}
